#include "VideoShare.hh"

VideoShare::VideoShare( int shareId, int64_t memSize )
    :Sharemem( shareId, memSize ){
}

VideoShare::VideoShare( int shareId, int chnNum )
    :Sharemem( shareId, chnNum ){
}
VideoShare::~VideoShare(){
}

VideoShare* VideoShare::createNewShare(int shareId, int64_t memSize )
{
    return new VideoShare( shareId, memSize );
}
VideoShare* VideoShare::createReadShare(int shareId, int chnNum )
{
    return new VideoShare( shareId, chnNum );
}

void VideoShare::moveReadPtr()
{
#if 1
    /*over writePtr to next keyFrame*/
    this->readPtrMoveToNextKeyFrame();
    /* FRAME_HEAD *minFrame = D_FRAME_HEAD( this->getMinReadPtr() ); */
    /* long long nextFrameAdd = minFrame->nextKeyFrame; */

    /* for( int i=0; i<MAX_CHN_NUM; i++ ){ */
    /*     if( D_MEM_HEAD->writePtr > nextFrameAdd > D_MEM_HEAD->readPtr[i] ){ */
    /*         D_MEM_HEAD->readPtr[i] = nextFrameAdd; */
    /*     }else if( ( D_MEM_HEAD->writePtr < nextFrameAdd ) && */
    /*               ( D_MEM_HEAD->writePtr < D_MEM_HEAD->readPtr[i] < nextFrameAdd ) */
    /*             ){ */
    /*         D_MEM_HEAD->readPtr[i] = nextFrameAdd; */
    /*     } */
    /* } */
#else
    /*over writePtr to next Frame*/
        this->readPtrMoveToNextFrame();
#endif
}

void VideoShare::getMediaInfo( const char *data, PAYLOAD_TYPE_E &mediaType, bool &keyFrame, struct timeval tvl )
{
    static timeval last_tvl = { 0, 0 };
    mediaType = PT_G711A;
    if( last_tvl.tv_sec != tvl.tv_sec )
    {
        keyFrame = true;
    }else
    {
        keyFrame = false;
    }

    last_tvl = tvl;
}
